package repman;

import java.awt.Component;

import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

import org.w3c.dom.CharacterData;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class RepTreeCellRenderer extends DefaultTreeCellRenderer
{  
   public Component getTreeCellRendererComponent(JTree tree, Object value, 
      boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
   {  
      super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
	  Element node = (Element) value;
	  //setText(node.getAttribute("name"));
	  if (node.getTagName() == "group") {
			  setText(node.getAttribute("name"));
					  }
	  else if (node.getTagName() == "report"){
	  		  setText(node.getTextContent());
	  }
	  else {
		  setText(node.toString());
	  }
      return this;
   }
}